//表单中字典字段	
var dictFields = ["refuseCpMsg"];
//字典类型 顺序与表单字典字段对应
var dictKeys = ["refuseCpMsg"];
var dicDatas = {};

$().ready(function() {
	initDictDatas();
	validateRule();
});

$.validator.setDefaults({
	submitHandler : function() {
		save();
	}
});
//构建字典数据
function initDictDatas(){
	$.ajax({
		url : ctx+'/common/dict/listdictbykeys',
		data : {'dictKeys':dictKeys},
		async : false,//同步执行
		success : function(data) {
			dicDatas = data;
		}
	});
	
	var thatDictFields = window.parent.dictFields;
	var thatDictkeys = window.parent.dictKeys;
	var thatDictDatas = window.parent.dicDatas;
	
	$('#checkInfo').bootstrapSelect({
		data:dicDatas['refuseCpMsg'],
		valueField: 'value',
		textField: 'name',
		placeholder: "请选择拒绝原因"
	});
	//$('#checkInfo').bootstrapSelect('setValue',1);
}
function save() {
	$.ajax({
		cache : true,
		type : "POST",
		url : ctx+"/coupon/cpExamine/refuse",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(r) {
			if (r.code==0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);
			}else{
				parent.layer.alert(r.msg)
			}

		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			checkInfo : {
				required : true
			}
		},
		messages : {
			checkInfo : {
				required : "请输入拒绝原因"
			}
		}
	})
}